<?php

namespace app\admin\controller;

use app\admin\service\ActivityService;

/**
 * @desc 抽奖活动
 * Class Activity
 * @package app\admin\controller
 */
class Activity extends CommonController
{
    /**
     * @desc 活动列表
     * @return \think\response\Json|\think\response\View
     */
    public function index()
    {
        if ($this->isAjax())
        {
            $list = ActivityService::getPageList();
            return $this->success($list);
        }

        return view();
    }

    /**
     * @desc
     */
    public function edit()
    {
        $types = ActivityService::getCycleType();

        $data = [];
        if (!empty($this->request['id']))
        {
            $data = ActivityService::getById($this->request['id']);
        }
        if ($this->isAjax())
        {
            ActivityService::edit($this->request);
            return $this->success();
        }
        return view('', ['types' => $types, 'data' => $data]);
    }
}
